#define _CRT_SECURE_NO_WARNINGS 1

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
bool istree(struct TreeNode* root, struct TreeNode* subRoot)
{
    if (root == NULL && subRoot == NULL)
        return true;
    if (root == NULL || subRoot == NULL)
        return false;
    if (root->val != subRoot->val)
        return false;
    return istree(root->left, subRoot->left) && istree(root->right, subRoot->right);
}
bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot) {
    bool x = false;
    if (root == NULL)
        return x;
    if (root->val == subRoot->val)
    {
        x = istree(root, subRoot);
    }
    if (x)
        return x;
    return isSubtree(root->left, subRoot) || isSubtree(root->right, subRoot);
}